//跳跃游戏（medium）: https://leetcode.cn/problems/jump-game/
class Solution
{
public:
	bool canJump(vector<int>& nums)
	{
		int left = 0, right = 0, maxPos = 0, n = nums.size();
		while (left <= right)
		{
			if (maxPos >= n - 1)
			{
				return true;
			}

			for (int i = left; i <= right; i++)
			{
				maxPos = max(maxPos, nums[i] + i);
			}
			left = right + 1;
			right = maxPos;
		}
		return false;
	}
};

